home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / jag.h.z / jag.h
C/C++ Source or Header  |  1992-04-03  |  9KB  |  268 lines

  1. /*
  2.  * Structures used in jag (Interphase 4210 Jaguar) driver.
  3.  */
  4. #define JAG_CTLRS 8            /* max # of controllers */
  5. #define JAG_UPC 14            /* max units per controller */
  6. #define JAG_LUPC 16            /* logical units per controller */
  7. #define JAG_NCQE 15            /* number command queue entries */
  8. #define JAG_DMABURST 0
  9. #define JAG_SELTIMEOUT 250        /* 250 milliseconds */
  10. #define JAG_CMDTIMEOUT 0        /* no command timeout */
  11. #define JAG_VMETIMEOUT 0        /* 100 milliseconds */
  12. #define JAG_NRETRY 4            /* really 3 retries */
  13. #define JAG_LEN_SENSE 64        /* maximum accepted sense length */
  14. #define JAG_LEN_INQUIRY 128        /* maximum accepted inquiry length */
  15.  
  16. /* Master Control Status Block */
  17. struct jag_mcsb
  18. {
  19.     ushort    msr;        /* master status register */
  20.     ushort    mcr;        /* master control register */
  21.     ushort    iqar;        /* interrupt on CQE available */
  22.     ushort    qhdp;        /* CQE head pointer */
  23.     ushort    thaw;        /* thaw work queue register */
  24.     ushort    reserve1;
  25.     ushort    reserve2;
  26.     ushort    reserve3;
  27. };
  28.  
  29.  
  30. /* Controller Initialization Block */
  31. struct jag_cib
  32. {
  33.     ushort    ncqe;        /* number of command queue entries */
  34.     ushort    dmaburst;    /* DMA burst count */
  35.     ushort    normal_vec;    /* normal command completion vector */
  36.     ushort    error_vec;    /* errored command completion vector */
  37.     ushort    scsi0_id;    /* ID of Jaguar controller channel 0 */
  38.     ushort    scsi1_id;    /* ID of Jaguar controller channel 1 */
  39.     ushort    crb_offset;    /* offset of Command Response Block */
  40.     ushort    sel_timeout_h;    /* timeout in milliseconds for select */
  41.     ushort    sel_timeout_l;    /* timeout in milliseconds for select */
  42.     ushort    wq0_timeout_h;    /* timeout in 256ms for scsi commands in WQ 0 */
  43.     ushort    wq0_timeout_l;    /* timeout in 256ms for scsi commands in WQ 0 */
  44.     ushort    vme_timeout_h;    /* timeout in 30ms for VME transactions */
  45.     ushort    vme_timeout_l;    /* timeout in 30ms for VME transactions */
  46.     ushort    reserve1;
  47.     ushort    reserve2;
  48.     ushort    crb_memtype;    /* type, size, addr mod for offboard crb */
  49.     ushort    crb_addr_h;    /* address of offboard crb */
  50.     ushort    crb_addr_l;    /* address of offboard crb */
  51.     ushort    err_recovery;    /* flag to enable work queue freezing */
  52.     ushort    reserve3;
  53. };
  54.  
  55.  
  56. /* Command Queue Entry */
  57. struct jag_cqe
  58. {
  59.     ushort    qecreg;        /* queue entry control register */
  60.     ushort    iopbaddr;    /* addr for iopbs in HUS */
  61.                 /* mem type, size, addr mod for offboard */
  62.     union
  63.     {
  64.         ulong    on;
  65.         struct
  66.         {
  67.             ushort tagh;
  68.             ushort tagl;
  69.         } off;
  70.     } tag;
  71.     u_char    iopblen;    /* iopb length */
  72.     u_char    wq_num;        /* work queue number */
  73.     ushort    reserve1;
  74. };
  75.  
  76.  
  77. /* SCSI passthru IOPB structure (works for most other IOPB's) */
  78. struct jag_iopb
  79. {
  80.     ushort    cmd;        /* command to do */
  81.     ushort    options;    /* options on command */
  82.     ushort    status;        /* status byte returned from SCSI bus */
  83.     ushort    reserve1;
  84.     u_char    intvector;    /* normal (good) completion vector */
  85.     u_char    errvector;    /* error command completion vector */
  86.     ushort    intlevel;    /* interrupt level */
  87.     ushort    reserve2;
  88.     ushort    iopb_memtype;    /* xfer type, xfer size, addr mode for data */
  89.     ulong    addr;        /* address of data */
  90.     ulong    length;        /* max length of data to xfer */
  91.     ulong    reserve3;
  92.     ushort    reserve4;
  93.     ushort    unit;        /* unit to send command to */
  94.     u_char    scsi[12];    /* actual SCSI command */
  95. };
  96.  
  97.  
  98. /* Initialize Work Queue IOPB structure */
  99. struct jag_wqiopb
  100. {
  101.     ushort    cmd;        /* command to do */
  102.     ushort    options;    /* options on command */
  103.     ushort    status;        /* return status */
  104.     ushort    reserve1;
  105.     u_char    intvector;    /* normal (good) completion vector */
  106.     u_char    errvector;    /* error command completion vector */
  107.     ushort    intlevel;    /* interrupt level */
  108.     ushort    ngroup;        /* number of commands to group */
  109.     ushort    reserve2[7];
  110.     ushort    wqnum;        /* work queue number */
  111.     ushort    wopt;        /* work queue options */
  112.     ushort    nslots;        /* number of slots in work queue */
  113.     ushort    priority;    /* priority of this work queue */
  114.     ushort    timeout;    /* command timeout for this queue */
  115.     ushort    reserve3;
  116. };
  117.  
  118.  
  119. /* Command Response Block */
  120. struct jag_crb
  121. {
  122.     ushort    crsw;        /* Command Response Status Word */
  123.     ushort    reserve1;
  124.     ulong    tag;        /* command tag */
  125.     u_char    iopblen;    /* iopb length */
  126.     u_char    wq_num;        /* work queue number */
  127.     ushort    reserve2;
  128.     struct jag_iopb iopb;    /* returned iopb */
  129. };
  130.  
  131.  
  132. /* Configuration Status Block */
  133. struct jag_csb
  134. {
  135.     ushort    reserve1;
  136.     u_char    reserve2;
  137.     u_char    product[3];
  138.     ushort    reserve3;
  139.     u_char    reserve4;
  140.     u_char    variation;
  141.     ushort    reserve5;
  142.     u_char    reserve6;
  143.     u_char    fwrev[3];
  144.     ushort    reserve7;
  145.     u_char    fwdate[8];
  146.     ushort    reserve8;
  147.     ushort    bufsize;
  148.     ulong    reserve9;
  149.     u_char    id0;        /* SCSI id of controller on channel 0 */
  150.     u_char    id1;        /* SCSI id of controller on channel 1 */
  151.     u_char    lastsel0;    /* SCSI id of most recent selection channel 0 */
  152.     u_char    lastsel1;    /* SCSI id of most recent selection channel 1 */
  153.     u_char    phase0;        /* Phase sense on channel 0 */
  154.     u_char    phase1;        /* Phase sense on channel 1 */
  155.     u_char    reserveA;
  156.     u_char    daughter;    /* Type of daughter board */
  157.     u_char    reserveB;
  158.     u_char    SW_DIP;        /* Status of switches on switch block SW2 */
  159.     ushort    frozenwq;    /* Frozen Work Queues bitmap */
  160. };
  161.  
  162.  
  163. /*
  164.  * Macros for determining unit number and controller number
  165.  */
  166. #define JAGCTLR(dev) ((dev & 0x700) >> 8)
  167. #define JAGUNIT(dev) ((int) jag_unitnum[(dev & 0xF0) >> 4])
  168. #define JAGFS(dev) (dev & 0xF)
  169.  
  170.  
  171. /*
  172.  * Driver structures.  The jagunitqueue structure must look something
  173.  * like the iobuf.  It must at least be identical up to the b_actl field.
  174.  */
  175. struct jagunitqueue
  176. {
  177.     sema_t     fill;        /* replaces b_lock in iobuf */
  178.     int     b_flags;    /* see buf.h */
  179.     struct buf *b_forw;    /* first buffer from strategy */
  180.     struct buf *b_back;    /* last buffer from strategy */
  181.     struct buf *b_actf;    /* head of I/O queue (b_forw)*/
  182.     struct buf *b_actl;    /* tail of I/O queue (b_back)*/
  183.     short     qlength;    /* number of bufs waiting for this unit */
  184.     char     specialwait;    /* there is a driver generated i/o waiting */
  185.     char     speciallen;    /* length of scsi command */
  186.     uint     specialtime;    /* timeout wait for special command */
  187. };
  188.  
  189.  
  190. struct jagunitinfo
  191. {
  192.     u_char      number;    /* unit number of this unit (0-13) */
  193.     u_char      devnum;    /* device number (0-15) */
  194.     u_char      present;    /* unit is connected */
  195.     u_char      status;    /* unit is busy with a command */
  196.     u_char      attn;        /* unit attention occurred */
  197.     struct jagunitqueue *queue; /* pointer to device's queue */
  198.     int      timeout_id;    /* timeout id */
  199.     dmamap_t *dmamap;    /* dmamap associated with unit */
  200.     struct jag_iopb iopb;    /* used for driver generated requests */
  201.     sema_t      iopbsema;
  202.     sema_t      iopbdone;
  203.     char      iopbsense[JAG_LEN_SENSE]; /* sense for driver gen'd reqs */
  204.     ushort      iopberror;    /* iopb error retry counter */
  205.     char      iopbsvalid;    /* sense data valid flag */
  206.     char      sense_err;    /* sense error indicator */
  207.     char     *sensedata;    /* request sense data */
  208.     char     *inq;        /* inquiry data */
  209.     uint      capacity[2];    /* disk capacity in sectors */
  210.     struct volume_header *vh; /* disk volume header */
  211. };
  212.  
  213. /* constants for jagunitinfo.present */
  214. #define JAG_UI_TAPE 1
  215. #define JAG_UI_DISK 2
  216.  
  217. /* constants for jagunitinfo.status */
  218. #define JAG_UISTAT_IDLE 0    /* no iopb outstanding for unit */
  219. #define JAG_UISTAT_REG 1    /* regular read/write iopb outstanding */
  220. #define JAG_UISTAT_SPEC 2    /* special driver generated iopb oustanding */
  221. #define JAG_UISTAT_SENSE 4    /* request sense outstanding */
  222.  
  223.  
  224. struct jagctlrinfo
  225. {
  226.     lock_t     lock;
  227.     u_char     number;    /* number of this controller */
  228.     u_char     present;    /* flag indicating if ctlr is installed */
  229.     u_char     vmebusno;    /* number of VME bus ctlr is installed in */
  230.     ushort     cmdcount;    /* count of outstanding commands */
  231.     u_char     reset[2];    /* set if resetting scsi busses */
  232.     volatile struct jag_mcsb *mcsb; /* short i/o master command/status */
  233.     volatile struct jag_cqe *mce; /* short i/o master command entry */
  234.     volatile struct jag_cqe *cmdq; /* short i/o command queue pointer */
  235.     volatile short *hus;    /* host usable space pointer */
  236.     volatile struct jag_crb *crb; /* off board command response block */
  237.     volatile struct jag_csb *csb; /* configuration status block pointer */
  238.     struct jagunitinfo *unit[JAG_UPC]; /* unit info */
  239. };
  240.  
  241.  
  242. struct memcqe
  243. {
  244.     volatile struct jag_cqe *cqe_offboard; /* pointer to offboard cqe */
  245.     struct jag_cqe cqe;    /* command queue entry for the unit */
  246.     struct jag_iopb iopb;    /* iopb for the unit */
  247. };
  248.  
  249.  
  250. struct jagrequest
  251. {
  252.     u_char    *scsicmd;    /* scsi command */
  253.     uint     scsilen;    /* length of scsi command */
  254.     char    *sense;        /* sense data from command if any */
  255.     char    *buffer;    /* location of data */
  256.     uint     buflen;    /* amount of data to transfer */
  257.     uint     direction;    /* read = 1 */
  258.     uint     timeout;    /* in seconds */
  259. };
  260.  
  261. /* defines for jagrequest.direction */
  262. #define JDIR_IN_CLEAN    0    /* receive data from peripheral */
  263. #define JDIR_OUT_CLEAN    1    /* send data to peripheral */
  264. #define JDIR_IN_DIRTY    2    /* needs a dcache_inval */
  265. #define JDIR_OUT_DIRTY    3    /* needs a dcache_wb */
  266. #define JDIR_OUT    1    /* bit mask */
  267. #define JDIR_DIRTY    2    /* bit mask */
  268.